package com.itboye.jmsfhz.data.presenter;

import java.util.List;
import java.util.Observer;

import android.util.Log;

import com.itboye.core.interfaces.ICompleteListener;
import com.itboye.core.object.BasePresenter;
import com.itboye.core.object.ResultEntity;
import com.itboye.jmsfhz.app.ui.main.MainPresenter;
import com.itboye.jmsfhz.data.interfaces.IPrisenter;
import com.itboye.jmsfhz.data.interfaces.IProjectrisenter;
import com.itboye.jmsfhz.data.model.ProjectBean;
import com.itboye.jmsfhz.data.repository.PrisenterRepository;
import com.itboye.jmsfhz.data.repository.ProjectrRepository;
import com.lfh.commentdemo.bean.AppModelNewsBean;

public class Projectpresenter extends BasePresenter implements IProjectrisenter<ProjectBean>{

	public static final String TouSuccessEvent = MainPresenter.class
			.getName() + "_Tou_success";
	public static final String TouFailEvent = MainPresenter.class
			.getName() + "_Tou_failure";
	
	
	
	public static final String meTouSuccessEvent = MainPresenter.class
			.getName() + "_meTou_success";
	public static final String meTouFailEvent = MainPresenter.class
			.getName() + "_meTou_failure";
	
	
	public static final String ProjectSuccessEvent = MainPresenter.class
			.getName() + "_Project_success";
	public static final String ProjectFailEvent = MainPresenter.class
			.getName() + "_Project_failure";
	
	

	public static final String jianliSuccessEvent = MainPresenter.class
			.getName() + "_jianli_success";
	public static final String jianliFailEvent = MainPresenter.class
			.getName() + "_jianli_failure";
	
	
	

	public static final String ProjectUpdateSuccessEvent = MainPresenter.class
			.getName() + "_ProjectUpdate_success";
	public static final String ProjectUpdateFailEvent = MainPresenter.class
			.getName() + "_jProjectUpdate_failure";
	
	
	
	public static final String ProjectKeySuccessEvent = MainPresenter.class
			.getName() + "_ProjectKey_success";
	public static final String ProjectKeyFailEvent = MainPresenter.class
			.getName() + "_jProjectKey_failure";
	
	public Projectpresenter(Observer observer) {
		super(observer);
		// TODO Auto-generated constructor stub
	}

	@Override
	public void add(ProjectBean model) {
		// TODO Auto-generated method stub
		IProjectrisenter<ProjectBean> banner = new ProjectrRepository(
				new ICompleteListener() {

					@Override
					public void success(ResultEntity result) {
						// TODO Auto-generated method stub
						Log.v("MainPresenter", "lunbo success");
						result.setEventTag(Tag_Success);
						result.setEventType(ProjectKeySuccessEvent);
						setChanged();
						notifyObservers(result);
					}

					@Override
					public void failure(ResultEntity result) {
						// TODO Auto-generated method stub
						Log.v("MainPresenter", "lunbo fail");
						result.setEventTag(Tag_Error);
						result.setEventType(ProjectKeyFailEvent);
						setChanged();
						notifyObservers(result);
					}
				});
		banner.add(model);
	}

	@Override
	public void delete(ProjectBean model) {
		// TODO Auto-generated method stub
		
	}

	@Override
	public void update(ProjectBean model) {
		// TODO Auto-generated method stub
		IProjectrisenter<ProjectBean> banner = new ProjectrRepository(
				new ICompleteListener() {

					@Override
					public void success(ResultEntity result) {
						// TODO Auto-generated method stub
						Log.v("MainPresenter", "lunbo success");
						result.setEventTag(Tag_Success);
						result.setEventType(ProjectSuccessEvent);
						setChanged();
						notifyObservers(result);
					}

					@Override
					public void failure(ResultEntity result) {
						// TODO Auto-generated method stub
						Log.v("MainPresenter", "lunbo fail");
						result.setEventTag(Tag_Error);
						result.setEventType(ProjectFailEvent);
						setChanged();
						notifyObservers(result);
					}
				});
		banner.update(model);
	}

	@Override
	public void getInfo(ProjectBean model) {
		// TODO Auto-generated method stub
		IProjectrisenter<ProjectBean> banner = new ProjectrRepository(
				new ICompleteListener() {

					@Override
					public void success(ResultEntity result) {
						// TODO Auto-generated method stub
						Log.v("MainPresenter", "lunbo success");
						result.setEventTag(Tag_Success);
						result.setEventType(ProjectSuccessEvent);
						setChanged();
						notifyObservers(result);
					}

					@Override
					public void failure(ResultEntity result) {
						// TODO Auto-generated method stub
						Log.v("MainPresenter", "lunbo fail");
						result.setEventTag(Tag_Error);
						result.setEventType(ProjectFailEvent);
						setChanged();
						notifyObservers(result);
					}
				});
		banner.getInfo(model);
	}

	@Override
	public List<ProjectBean> query(ProjectBean model) {
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public void getTou(String uid) {
		// TODO Auto-generated method stub
		IProjectrisenter<ProjectBean> banner = new ProjectrRepository(
				new ICompleteListener() {

					@Override
					public void success(ResultEntity result) {
						// TODO Auto-generated method stub
						Log.v("MainPresenter", "lunbo success");
						result.setEventTag(Tag_Success);
						result.setEventType(meTouSuccessEvent);
						setChanged();
						notifyObservers(result);
					}

					@Override
					public void failure(ResultEntity result) {
						// TODO Auto-generated method stub
						Log.v("MainPresenter", "lunbo fail");
						result.setEventTag(Tag_Error);
						result.setEventType(meTouFailEvent);
						setChanged();
						notifyObservers(result);
					}
				});
		banner.getTou(uid);
	}

	@Override
	public void getJianLi(String uid, String id) {
		// TODO Auto-generated method stub
		IProjectrisenter<ProjectBean> banner = new ProjectrRepository(
				new ICompleteListener() {

					@Override
					public void success(ResultEntity result) {
						// TODO Auto-generated method stub
						Log.v("MainPresenter", "lunbo success");
						result.setEventTag(Tag_Success);
						result.setEventType(jianliSuccessEvent);
						setChanged();
						notifyObservers(result);
					}

					@Override
					public void failure(ResultEntity result) {
						// TODO Auto-generated method stub
						Log.v("MainPresenter", "lunbo fail");
						result.setEventTag(Tag_Error);
						result.setEventType(jianliFailEvent);
						setChanged();
						notifyObservers(result);
					}
				});
		banner.getJianLi(uid,id);
	}
	@Override
	public void getProject(String uid, String id) {
		// TODO Auto-generated method stub
		IProjectrisenter<ProjectBean> banner = new ProjectrRepository(
				new ICompleteListener() {

					@Override
					public void success(ResultEntity result) {
						// TODO Auto-generated method stub
						Log.v("MainPresenter", "lunbo success");
						result.setEventTag(Tag_Success);
						result.setEventType(ProjectUpdateSuccessEvent);
						setChanged();
						notifyObservers(result);
					}

					@Override
					public void failure(ResultEntity result) {
						// TODO Auto-generated method stub
						Log.v("MainPresenter", "lunbo fail");
						result.setEventTag(Tag_Error);
						result.setEventType(ProjectUpdateFailEvent);
						setChanged();
						notifyObservers(result);
					}
				});
		banner.getProject(uid,id);
	}

	@Override
	public void getShouDao(String uid, String page_num, String page_size) {
		// TODO Auto-generated method stub
		IProjectrisenter<ProjectBean> banner = new ProjectrRepository(
				new ICompleteListener() {

					@Override
					public void success(ResultEntity result) {
						// TODO Auto-generated method stub
						Log.v("MainPresenter", "lunbo success");
						result.setEventTag(Tag_Success);
						result.setEventType(TouSuccessEvent);
						setChanged();
						notifyObservers(result);
					}

					@Override
					public void failure(ResultEntity result) {
						// TODO Auto-generated method stub
						Log.v("MainPresenter", "lunbo fail");
						result.setEventTag(Tag_Error);
						result.setEventType(TouFailEvent);
						setChanged();
						notifyObservers(result);
					}
				});
		banner.getShouDao(uid, page_num, page_size);
	}

}
